<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Career Site</title>
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
	<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
	<link href="<c:url value="/resources/css/header.css" />" rel="stylesheet"/>
	<link href="<c:url value="/resources/css/common.css" />" rel="stylesheet"/>
	<link href="<c:url value="/resources/css/footer.css"/>" rel="stylesheet"/>
	<link href="<c:url value="/resources/css/login.css"/>" rel="stylesheet"/>
</head>
<body class="login-page">
<%@ include file="common/header.jsp" %>
	<div class="body--container container-fluid main-body--wrapper row-fluid content-container--wrapper docs--body">
			
			 <div class="login_account">
					<form action="../j_spring_security_check" method="post" >
					<h2>Sign in using your Careersite Account</h2>	
						<div id="login-error">${error}</div>	
					<p>
						<label for="j_username">Username</label>
						<input id="j_username" name="j_username" type="text" />
					</p>
					
					<p>
						<label for="j_password">Password</label>
						<input id="j_password" name="j_password" type="password" />
					</p>
					<input class="submit" type="submit" value="Login"/>		
						
					</form>
					<a class="forgot">Forgotten your password?</a>
			</div>	
			<div class="login_social_network">
				<h2>Sign in using Facebook or Twitter</h2>
				<div class="social-facebook">
					<script>
						 window.fbAsyncInit = function() {
							    // init the FB JS SDK
							    FB.init({
							      appId      : 836656756349374,                        // App ID from the app dashboard
							   //   channelUrl : '${facebookChannelUrl}', // Channel file for x-domain comms
							      status     : true,                                 // Check Facebook Login status
							      xfbml      : true                                  // Look for social plugins on the page
							    });
		
							    // Additional initialization code such as adding Event Listeners goes here
							    <c:if test="${param.fb=='true'}">
								FB.login(function(response) {
							        if (response.authResponse) {
							        	var accessToken = response.authResponse.accessToken;					        	
							            window.location.href='<c:url value="/account/loginfb"/>?accessToken='+accessToken;
							        } else {
							        	
							        }
							    });
								</c:if>
								
							  };
									
									function fbLogin(data){
										FB.getLoginStatus(function(response) {
										  if (response.status === 'connected') {
										    // the user is logged in and has authenticated your
										    // app, and response.authResponse supplies
										    // the user's ID, a valid access token, a signed
										    // request, and the time the access token 
										    // and signed request each expire
										    var uid = response.authResponse.userID;
										    var accessToken = response.authResponse.accessToken;								   								    								    
										    FB.api('/me', function(response) {
										    	  //console.log(response);
										    	  var params=['accessToken='+accessToken
										    	              ,'uid='+uid
										    	              ,'email='+response.email								    	              
										    	              ,'name='+encodeURIComponent(response.name)].join('&');
									    	  window.location.href='<c:url value="/account/loginfb"/>?accessToken='+accessToken;
									    	});
									  } else if (response.status === 'not_authorized') {
									    // the user is logged in to Facebook, 
									    // but has not authenticated your app
									  } else {
									    // the user isn't logged in to Facebook.
									  }
									 });
								}
								</script>
									<div id="fb-root" style="display: none;"></div>
									<script>
										(function(d, s, id) {
											  var js, fjs = d.getElementsByTagName(s)[0];
											  if (d.getElementById(id)) return;
											  js = d.createElement(s); js.id = id;
											  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
											  fjs.parentNode.insertBefore(js, fjs);
											}(document, 'script', 'facebook-jssdk'));
									
								
								</script>
								<div class="fb-login-button" data-scope="email"data-size="medium" data-onlogin="fbLogin();" data-width="300">
											<spring:message code="account.login.facebook" text="Login with Facebook" />
								</div>
							</div>	
								<div class="social-twitter"> 
									<a title="Sign in with twitter" href="<c:url value="/account/twitter"/>" class="twitter_button_medium"> 
											<img src="../resources/images/btn-signin-with-twitter.png" alt="Login with Twitter" />
									</a>
								</div>
							<div class="social-linkedin">						
								<a class="linkedin_button_medium" href='<c:url  value="/account/linkedin"/>' title="Sign in with linkedin">
									<img alt="image" src="../resources/images/linkedin_signin_button.png">
								</a>												
							</div>	
			
		</div>
	</div>	
<%@ include file="common/footer.jsp" %>   
</body>
</html>